/*
 * 字符串转为ArrayBuffer对象
 * 根据步长确定转换的位数
 * @param {String} value 字符串
 * @param {Number} step 步长
 */
function toArrayBuffer(value, step) {
	console.log('step', step)
	const buffer = new ArrayBuffer(value.length * step)
	// const uintArray = `Uint${step * 8}Array`
	const arr = value.split('')
	
	// let view = new window[uintArray](buffer)
	
	let view = step == 2 ?
		new Uint16Array(buffer) :
		new Uint8Array(buffer)
	
	arr.map((d, i) => view[i] = d.charCodeAt())
	return buffer		
}

export {
	toArrayBuffer
}